package cosc617_blackteam;


/**
 *
 * @author Anton
 */
public class CmdGetComments implements I_Command {

    private I_InfoAggregator infoAggr;

    public CmdGetComments(I_InfoAggregator infoAggr) {
        this.infoAggr = infoAggr;
    }

    /*
     * @return a copy of all comments in a collection.
     */
    @Override
    public Object execute() {
        I_CommentIterator ci = this.infoAggr.getComments().getDefaultCommentIterator();
        CommentCollection comments = new CommentCollection();
        while (ci.hasNext()) {
            comments.addComment(ci.next().copy());
        }
        return comments;
    }

}
